<?php 


$startDate = $viewDate;
$endDate = $viewDate;


echo '<table>';
echo '<tr>';
echo '<th>Employees</th>';
echo '<th>Role</th>';
echo '<th>Start</th>';
echo '<th>End</th>';
echo '<th>Status</th>';
echo '<th>Actions</th>';
echo '</tr>';


$getAccountsResult = getAccounts($userName, $userPassHash);
$accounts = null;
//grab the accounts
$accounts = $getAccountsResult['results'];
//parse the accounts
foreach ($accounts as &$accountsEntry) {
	$accName=$accountsEntry['accName'];

	$getAccountResult = getAccount($accName, $userName, $userPassHash);
	$_SESSION[$accName . 'account'] = $getAccountResult['results']['dataHash'];
	getShiftsPerWorker($startDate, $endDate, $accName, $userName, $userPassHash);
}
echo '</table>';

function getShiftsPerWorker($startDate, $endDate, $accName, $userName, $userPassHash)
{
	$checkRangeSchedulePerWorkerResult = checkRangeSchedulePerWorker($userName, $userPassHash, date("Y-m-d", $startDate), date("Y-m-d", $endDate), $accName);
	$shifts = null;

	//grab the shifts
	$shifts = $checkRangeSchedulePerWorkerResult[1];

	//display only if employee has shift on that day
	if ($shifts != null)
	{
		//parse the shifts
		echo '<form action="template.php">';
		echo '<tr>';
		echo '<td>';
		echo $accName;

		//hidden fields
		echo '<input type="hidden" name="roleID" value="'. $shifts[0]['roleID'] .'">';
		echo '<input type="hidden" name="dateID" value="'. $shifts[0]['dateID'] .'">';
		echo '<input type="hidden" name="empID" value="'. $shifts[0]['empID'] .'">';

		echo '</td>';

		//Role
		echo '<td>'. $shifts[0]['roleName'] .'</td>';

		//Start
		echo '<td>'. $shifts[0]['startTime'] .'</td>';

		//End
		echo '<td>'. $shifts[0]['endTime'] .'</td>';

		//Status
		echo '<td>'. $shifts[0]['shiftStatus'] .'</td>';

		//Actions
		echo '<td>';
		echo '<input type="submit" name="shiftAction" value="Delete Shift" />';
		echo '</td>';

		echo '</tr>';
		echo '</form>';
	}
}

?>